﻿<div class="container padding-10">
    <style>
        .box {
            width: 2rem;
            height: 2rem;
        }

        .red-bg {
            background-color: red;
        }

        .green-bg {
            background-color: green;
        }
    </style>
    <!--鼠标移入移出-->
    <div class="box"
         data-bind="css: {'red-bg': mouseIn(), 'green-bg': !mouseIn()},
         event:{mouseenter: handleMouseEnter, mouseleave: handleMouseLeave}"></div>

    <!--下拉框的change事件-->
    <form class="form-inline margin-t-md">
        <div class="form-group">
            <label for="hobbies">爱好：</label>
            <select id="hobbies" class="form-control" style="width: 2rem"
                    data-bind="options:hobbies, optionsText:'name', optionsValue:'id', value:selectedHobbyId, event:{ change: changeHobby }"></select>
        </div>
        <div class="form-group margin-l-lg">
            <label>选中的爱好是：</label>
            <span data-bind="text: selectedHobbyName"></span>
        </div>
    </form>
</div>

